package backend.majiong.yaku.yaku;

import java.util.HashSet;
import java.util.Set;

import backend.MainGame;
import backend.majiong.Pai;
import backend.majiong.Player;
import backend.majiong.yaku.AbstractYaku;
import backend.majiong.yaku.HandCombo;

public class SansyokuDoujun extends AbstractYaku {

    @Override
    public boolean checkYaku(Player player, HandCombo combo, MainGame mainGame) {
        Set<Integer> wan = new HashSet<Integer>();
        Set<Integer> suo = new HashSet<Integer>();
        Set<Integer> pin = new HashSet<Integer>();
        for (Pai pai : combo.getSunZi()) {
            if (Pai.TYPE_PIN.equals(pai.getType())) {
                pin.add(pai.getNum());
            }
            if (Pai.TYPE_SOU.equals(pai.getType())) {
                suo.add(pai.getNum());
            }
            if (Pai.TYPE_WAN.equals(pai.getType())) {
                wan.add(pai.getNum());
            }
        }
        for (int i = 1; i < 10; i++) {
            if (wan.contains(i) && suo.contains(i) && pin.contains(i)) {
                return true;
            }
        }
        return false;
    }

    @Override
    public String getYakuName() {
        return "三色同顺";
    }

    @Override
    public Integer getYakuNum(boolean isMenQing) {
        if(isMenQing) {
            return 2;
        }
        return 1;
    }

}
